package bishi.didi;

import java.rmi.MarshalException;
import java.util.*;

public class demo1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int[] arry = new int[n];
        for(int i = 0;i < n;i++) {
            arry[i] = in.nextInt();
        }
        Arrays.sort(arry);
        //降序
        for(int i = 0,j = n - 1;i < j;i++,j--) {
            int temp = arry[i];
            arry[i] = arry[j];
            arry[j] = temp;
        }
        int total = 0;
        int pre = Integer.MAX_VALUE;
        for(int x : arry) {
            int cur = Math.min(x,pre - 1);
            if(cur <= 0) {
                break;
            }
            total += cur;
            pre = cur;
        }
        System.out.println(total);
    }
}
